<template>
  <div class="son">
    <h3>我是子组件</h3>
    <h4>{{ num }}</h4>
    <button @click="btnClick">点击++</button>
  </div>
</template>
<script>
export default {
  props: {
    num: {
      type: Number,
      required: true
    //   validator: (val) => {
    //     return val >= 5
    //   }
      // default
      // validator:()=>{}
    }
  },
  methods: {
    btnClick() {
      this.$emit('update:num', this.num + 1)
    }
  }
}
</script>
<style lang="scss" scoped>
.son{
    width: 300px;
    height: 300px;
    background-color: #f00;
}
</style>
